home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / fmodla13.zip / FILES.DEF < prev    next >
Text File  |  1992-01-29  |  5KB  |  180 lines

  1. DEFINITION MODULE Files;
  2.  
  3. (* (C) Copyright 1987 Fitted Software Tools. All rights reserved. *)
  4.  
  5. (*
  6.     DOS File Management Interface module
  7.  
  8.     If more information about these procedures, error codes, etc is
  9.     needed, please consult the DOS technical reference manual.
  10. *)
  11.  
  12. FROM SYSTEM IMPORT ADDRESS;
  13.  
  14. CONST (* the standard files *)
  15.  
  16.     StdIn  = 0;
  17.     StdOut = 1;
  18.     StdErr = 2;
  19.     StdCom = 3;
  20.     StdPrn = 4;
  21.  
  22.  
  23. CONST (* file attribute bits - to be used on Create call.
  24.          You may add several of these attributes together
  25.        *)
  26.  
  27.     NORMAL      = {};
  28.     READONLY    = {0};
  29.     HIDDEN      = {1};
  30.     SYSTEM      = {2};
  31.  
  32.  
  33. CONST (* file open mode flags - for building mode flags for the Open call.
  34.          You must pick 1 from the first group.
  35.          You may pick one more from each of the other groups and add
  36.          them all together
  37.        *)
  38.  
  39.     READ    = {};               (* open file for reading *)
  40.     WRITE   = {0};              (* open file for writing *)
  41.     IO      = {1};              (* open file for reading and writing *)
  42.  
  43.         (* the following are for use under DOS 3.x only *)
  44.  
  45.     NOINHERIT   = {7};          (* do not let child inherit this file *)
  46.  
  47.     DENYALL     = {4};          (* deny all access to other processes *)
  48.     DENYWRITE   = {5};          (* deny write access to other processes *)
  49.     DENYREAD    = {4,5};        (* deny read access to other processes *)
  50.     DENYNONE    = {6};          (* allow free access to other processes *)
  51.  
  52.  
  53. TYPE (* seek mode - for use with Seek *)
  54.  
  55.     SeekMode = ( SEEKABS,       (* seek to the location specified *)
  56.                  SEEKCUR,       (* the location specified is relative to the
  57.                                    value of the current file pointer *)
  58.                  SEEKEND        (* the location specified is relative to the
  59.                                    end of file *)
  60.                );
  61.  
  62.  
  63. VAR (* DOS error code for the last Files function *)
  64.  
  65.     FileStatus :CARDINAL;       (* =0 if the last call was successful *)
  66.  
  67.  
  68. PROCEDURE Open( VAR fd :INTEGER; name :ARRAY OF CHAR; mode :BITSET );
  69. (*
  70.     Open a file according to mode.
  71.  
  72.     On return, fd will contain the file descriptor value returned by DOS,
  73.     or -1 if an error occured.
  74. *)
  75.  
  76. PROCEDURE Create( VAR fd :INTEGER; name :ARRAY OF CHAR; attr :BITSET );
  77. (*
  78.     Create a new file or truncate an existing one.
  79.  
  80.     If Create is successful, the file will be open for read and write and
  81.     fd will contain the file descriptor value returned by DOS.
  82.     If Create fails, fd will contain -1.
  83. *)
  84.  
  85. PROCEDURE CreateTemp( VAR fd :INTEGER; VAR path :ARRAY OF CHAR; attr :BITSET );
  86. (*
  87.     Used under DOS 3.x to create a new uniquely named temporary file.
  88.     On entry, path should contain the path name of the directory
  89.     where the temporary file is to be placed and enough space (14
  90.     bytes) where DOS will place the temporary name.
  91.  
  92.     On return, path will contain the complete name of the temporary
  93.     file.
  94.  
  95.     NOTE: DOS does not automatically delete temporary files. You must
  96.     delete the file once you no longer need it.
  97. *)
  98.  
  99. PROCEDURE CreateNew( VAR fd :INTEGER; name :ARRAY OF CHAR; attr :BITSET );
  100. (*
  101.     Similar to Create, but fails if the file already exists (DOS 3.x).
  102. *)
  103.  
  104. PROCEDURE Close( fd :INTEGER );
  105. (*
  106.     Close the file.
  107.     Any further I/O using this file descriptor would be an error.
  108. *)
  109.  
  110. PROCEDURE Read( fd :INTEGER; buffer :ADDRESS; bytes :CARDINAL;
  111.                 VAR nread :CARDINAL );
  112. (*
  113.     Read the specified number of bytes from the file.
  114.  
  115.     On return, nread contains the actual number of bytes read.
  116. *)
  117.  
  118. PROCEDURE Write( fd :INTEGER; buffer :ADDRESS; bytes :CARDINAL;
  119.                  VAR nwritten :CARDINAL );
  120. (*
  121.     Write the specified number of bytes to the file.
  122.  
  123.     On return, nwritten contains the actual number of bytes written.
  124. *)
  125.  
  126. PROCEDURE Seek( fd :INTEGER; mode :SeekMode; VAR offset :LONGCARD );
  127. (*
  128.     Move the file pointer to the location specified by offset,
  129.     according to the strategy specified in mode.
  130.  
  131.     On return, offset contains the new file pointer location.
  132. *)
  133.  
  134. PROCEDURE Lock( fd :INTEGER; offset :LONGCARD; length :LONGCARD );
  135. (*
  136.     Lock the file region starting at offset for length bytes (DOS 3.x).
  137. *)
  138.  
  139. PROCEDURE Unlock( fd :INTEGER; offset :LONGCARD; length :LONGCARD );
  140. (*
  141.     Unlock the file region starting at offset for length bytes (DOS 3.x).
  142. *)
  143.  
  144. PROCEDURE Dup( fd :INTEGER; VAR newfd :INTEGER );
  145. (*
  146.     Return newfd, a new file descriptor for the file referenced by fd.
  147. *)
  148.  
  149. PROCEDURE Dup2( fd, fd2 :INTEGER );
  150. (*
  151.     Force fd2 to refer to the same file as fd.
  152. *)
  153.  
  154. PROCEDURE GetFileTime( fd :INTEGER; VAR time :LONGCARD );
  155. (*
  156.     returns in time the date and time of last modification of the file.
  157.  
  158.     time DIV 65536L = date of last modification
  159.     time MOD 65536L = time of last modification
  160. *)
  161.  
  162. PROCEDURE SetFileTime( fd :INTEGER; time :LONGCARD );
  163. (*
  164.     Sets the file's modification date and time.
  165. *)
  166.  
  167. PROCEDURE Rename( oldname, newname :ARRAY OF CHAR );
  168. (*
  169.     Change the name of the file oldname to newname.
  170.  
  171.     Rename can be used to move a file to another subdirectory
  172.     in the same drive.
  173. *)
  174.  
  175. PROCEDURE Delete( name :ARRAY OF CHAR );
  176. (*
  177.     Delete the named file.
  178. *)
  179.  
  180. END Files.